package com.yl.applicationsecurity.service.Impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yl.applicationsecurity.mapper.UserMapper;
import com.yl.applicationsecurity.pojo.Inspection;
import com.yl.applicationsecurity.pojo.User;
import com.yl.applicationsecurity.service.UserService;
import com.yl.applicationsecurity.utils.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<com.yl.applicationsecurity.mapper.UserMapper, User> implements UserService{
    @Autowired
    private UserMapper UserMapper;
    @Override
    public User findByUsername(String username)  {
        return UserMapper.findByUsername(username);
    }

    @Override
    public Integer updatePwd(String username, String oldPwd, String newPwd) {
        LambdaUpdateWrapper<User> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
        lambdaUpdateWrapper.set(User::getPassword, Md5Util.getMD5String(newPwd)).eq(User::getUsername , username);
        return baseMapper.update(null,lambdaUpdateWrapper);
    }
}
